Shader "Level4/UV/UVAnimation"{
	Properties{
		_MainTex("MainTex",2d) = ""{}
		_TileX("Tile X",float) = 6
		_TileY("Tile Y",float) = 6
		_FrameX("Frame X",float) = 0
		_FrameY("Frame Y",float) = 0
	}
	
	CGINCLUDE
		#include "UnityCG.cginc"
		// float4 _MainTex_ST;
		sampler2D _MainTex;
		float _TileX;
		float _TileY;
		float _FrameX;
		float _FrameY;
		
		struct v2f{
			float4 pos:POSITION;
			float2 uv:TEXCOORD;
		};
		
		v2f vert(appdata_base v){
			v2f o;
			o.pos = mul(UNITY_MATRIX_MVP,v.vertex);
			o.uv = v.texcoord;
			float2 section = 1.0 / float2(_TileX,_TileY);
			//1
			o.uv *= section;
			//2
			o.uv += float2(_FrameX,_FrameY) * section;
			return o;
		}
		float4 frag(v2f v):COLOR{
			float4 texColor = tex2D(_MainTex,v.uv);
			return texColor;
		}
	ENDCG
	
	SubShader{
		Blend one oneMinusSrcColor
	
		Pass{
			CGPROGRAM
				#pragma vertex vert
				#pragma fragment frag
			ENDCG
		}
	}
}